import request from "@/utils/request";

// 用户相关API
const userApi = {
	//会员信息
	getUserinfo() {
		return request.get<dataResult>({ url: "/api/customer/home/userinfo" });
	},
	// 修改密码
	updateprofile(data : UpdatePasswordParams) {
		return request.post<dataResult>({ url: "/api/customer/home/updateprofile", data });
	},
	// 邀请列表
	getinvitelist(data : GetInviteIistParams) {
		return request.post<dataResult>({ url: "/api/customer/home/getinvitelist", data });
	},
	// 操作日志
	getloglist(data : GetLogListParams) {
		return request.post<dataResult>({ url: "/api/customer/home/getloglist", data });
	},
	// 资金明细
	getcapitalflow(data : GetCapitalFlowParams) {
		return request.post<dataResult>({ url: "/api/customer/home/getcapitalflow", data });
	},
	//会员等级列表
	getlevellist() {
		return request.get<dataResult>({ url: "/api/customer/home/getlevellist" });
	},
	// 升级等级
	upgrade(data : UpgradeParams) {
		return request.post<dataResult>({ url: "/api/customer/home/upgrade", data });
	},

	// 修改交易密码
	updatetradepassword(data : UpgradeParams) {
		return request.post<dataResult>({ url: "/api/customer/home/updatetradepassword", data });
	},
	// 更换api秘钥
	changeapikey(data : UpgradeParams) {
		return request.post<dataResult>({ url: "/api/customer/home/changeapikey", data });
	},
	// 更新api配置
	updateapiconfig(data : UpgradeParams) {
		return request.post<dataResult>({ url: "/api/customer/home/updateapiconfig", data });
	},
	// 分站版本
	getsubstationversionlist(data : UpgradeParams) {
		return request.post<dataResult>({ url: "/api/customer/home/getsubstationversionlist", data });
	},
	// 开通分站
	createsubstation(data : UpgradeParams) {
		return request.post<dataResult>({ url: "/api/customer/home/createsubstation", data });
	},
	// 统计信息
	statistics() {
		return request.get<dataResult>({ url: "/api/customer/home/statistics" });
	}
};

export default userApi;

interface dataResult {
	data ?: any;
	message : string;
	status : number;
}

//修改密码请求参数
interface UpdatePasswordParams {
	old_password : string;
	new_password : string;
}

//邀请列表请求参数
interface GetInviteIistParams {
	page : number;
	limit : number;
}

//操作日志请求参数
interface GetLogListParams {
	page : number;
	limit : number;
	type : string;
}

//资金明细请求参数
interface GetCapitalFlowParams {
	page : number;
	limit : number;
	type : string;
	action : string;
}

//升级等级
interface UpgradeParams {
	level : number;
	password : string;
}